package lw.badwordsfucker;

import okhttp3.*;

import java.io.IOException;

public class RequestAPI {
    static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build();

    public String getRawdata(String text) throws IOException {
        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
        RequestBody body = RequestBody.create(mediaType, "access_token=" + "24.817c0958b80a46527055c1f7a0fc7e03.2592000.1678706524.282335-30346475" + "&" + "text="+ text);
        Request request = new Request.Builder()
                .url("https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined?access_token=")
                .method("POST", body)
                .addHeader("Content-Type", "application/x-www-form-urlencoded")
                .addHeader("Accept", "application/json")
                .build();
        Response response = HTTP_CLIENT.newCall(request).execute();
        return response.body().string();
    }
}
